using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Framework.Module.CMS.Library.Contents;
using Framework.Library;
using Framework.Library.Utilities;
using Framework.Library.Components.Security;

namespace Framework.Module.CMS.Admin.WorkFlow
{
    public partial class ViewContent : AuthenticatedControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["contentid"] != null && Request.QueryString["contentid"] != "")
            {
                ContentInfo info = ContentController.GetInfo(ConvertUtility.ToInt32(Request.QueryString["contentid"]));
                if (info == null)
                {
                    Response.Redirect(AppEnv.ACCESSDENY);
                    return;
                }
                lnkHeadline.Text = info.Content_Headline;
                lblDate.Text = info.Content_CreateDate.ToString("dd-MM-yyyy");
                if (info.Content_Avatar != string.Empty)
                    imgAvatar.ImageUrl = MultimediaUtility.GetAvatar(info.Content_Avatar);
                else
                    imgAvatar.Visible = false;
                litTeaser.Text = info.Content_Teaser;
                litBody.Text = info.Content_Body;
            }
            else if (Request.QueryString["versionid"] != null && Request.QueryString["versionid"] != "")
            {
                ContentVersionInfo info = ContentVersionController.GetInfo(ConvertUtility.ToInt32(Request.QueryString["versionid"]));
                if (info == null)
                {
                    Response.Redirect(AppEnv.ACCESSDENY);
                    return;
                }
                lnkHeadline.Text = info.Content_Headline;
                lblDate.Text = info.Content_CreateDate.ToString("dd-MM-yyyy");
                if (info.Content_Avatar != string.Empty)
                    imgAvatar.ImageUrl = MultimediaUtility.GetAvatar(info.Content_Avatar);
                else
                    imgAvatar.Visible = false;
                litTeaser.Text = info.Content_Teaser;
                litBody.Text = info.Content_Body;
            }            
            else
            {
                Response.Redirect(AppEnv.ACCESSDENY);
            }
        }
    }
}